<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title>拼图后台管理-后台管理</title>
    <link rel="stylesheet" href="/Application/View/Admin/css/pintuer.css">
    <link rel="stylesheet" href="/Application/View/Admin/css/admin.css">
</head>

<body>
<div class="admin">
<form method="post" action="">
<div class="panel admin-panel">
<div class="panel-head"><strong>文章检索</strong>&nbsp;&nbsp;&nbsp;&nbsp;
	类别：
    <select name="cat_id">
    	<option value="">请选择类别</option>
    	{foreach $cat_list as $rows}
        	<option value="{$rows['cat_id']}" {(isset($smarty.post.cat_id) && $smarty.post.cat_id==$rows['cat_id'])?'selected':''}>{'&nbsp;'|str_repeat:($rows['deep']*4)}{$rows['cat_name']}</option>
        {/foreach}
    </select>
    标题：<input type="text" name="title" value="{(isset($smarty.post.title))?$smarty.post.title:''}">
    内容：<input type="text" name="content" value="{(isset($smarty.post.content))?$smarty.post.content:''}">
    是否公开：<select name="is_public">
    	<option value="">不限</option>
        <option value="1" {(isset($smarty.post.is_public) && $smarty.post.is_public==='1')?'selected':''}>是</option>
        <option value="0" {(isset($smarty.post.is_public) && $smarty.post.is_public==='0')?'selected':''}>否</option>
        </select>
    是否置顶：<select name="is_top">
    	<option value="">不限</option>
        <option value="1" {(isset($smarty.post.is_top) && $smarty.post.is_top==='1')?'selected':''}>是</option>
        <option value="0" {(isset($smarty.post.is_top) && $smarty.post.is_top==='0')?'selected':''}>否</option></select>
    <input type="submit"  value="搜索">
</div>
</div>
</form>
    <div class="panel admin-panel">
    	<div class="panel-head"><strong>内容列表</strong></div>
        <div class="padding border-bottom">
            <input type="button" class="button button-small checkall" name="checkall" checkfor="id"  onclick="checkAll(form1)"  value="全选" />
            <input type="button" class="button button-small checkall" name="checkall" checkfor="id" onclick="switchAll(form1)" value="反选" />
            <input type="button" class="button button-small checkall" name="checkall" checkfor="id" onclick="uncheckAll(form1)" value="选" />
            <input type="button" class="button button-small border-green" id="btn_recover" value="批量还原"/>
            <input type="button" class="button button-small border-yellow" id="btn_delete" value="批量删除"/>
            <input type="button" class="button button-small border-blue" id="btn_back" value="返回"/>
        </div>
<script type="text/javascript">
    //javascript全选、反选、选：

    function checkAll(form1){
        var elements=form1.getElementsByTagName('input');
        for(var i=0;i<elements.length;i++){
            if(elements[i].type=="checkbox"){
                if(elements[i].checked==false){
                    elements[i].checked=true;
                }
            }
        }
    }

    function switchAll(form1){
        var elements=form1.getElementsByTagName('input');
        for(var i=0;i<elements.length;i++){
            if(elements[i].type=="checkbox"){
                if(elements[i].checked==false){
                    elements[i].checked=true;
                }else if(elements[i].checked==true){
                    elements[i].checked=false;
                }
            }
        }
    }

    function uncheckAll(form1){
        var elements=form1.getElementsByTagName('input');
        for(var i=0;i<elements.length;i++){
            if(elements[i].type=="checkbox"){
                if(elements[i].checked==true){
                    elements[i].checked=false;
                }
            }
        }
    }

    //还原按钮脚本
    window.onload=function(){
        document.getElementById('btn_recover').onclick=function(){
            var art_id_checkbox=document.getElementsByName('art_id');	//获取所有的复选框
            var ids=[];													//保存选中的id
            for(var i=0,n=art_id_checkbox.length;i<n;i++){
                if(art_id_checkbox[i].checked){							//如果复选框选中
                    ids.push(art_id_checkbox[i].value);					//将复选框的id存放到数组中
                }
            }
            ids=ids.join();	//将id连接成逗号分隔的字符串
            if(ids=='')
                return;
            location.href='index.php?p=Admin&c=Article&a=rcRb&art_id='+ids;
        }
        //删除按钮脚本
        document.getElementById('btn_delete').onclick=function(){
            var art_id_checkbox=document.getElementsByName('art_id');	//获取所有的复选框
            var ids=[];													//保存选中的id
            for(var i=0,n=art_id_checkbox.length;i<n;i++){
                if(art_id_checkbox[i].checked){							//如果复选框选中
                    ids.push(art_id_checkbox[i].value);					//将复选框的id存放到数组中
                }
            }
            ids=ids.join();	//将id连接成逗号分隔的字符串
            if(ids=='')
                return;
            location.href='index.php?p=Admin&c=Article&a=delRb&art_id='+ids;
        }
        //返回按钮脚本
        document.getElementById('btn_back').onclick=function(){
            location.href='index.php?p=Admin&c=Article&a=list';         //跳转回文章管理页面
        }
    }
</script>

<form action="?" method="post" name="form1">
        <table class="table table-hover">
            <tr><th width="45">选择</th><th width="120">分类</th><th width="*">名称</th><th>置顶</th><th>公开</th><th width='100'>评论数</th><th width="200">时间</th><th width="200">操作</th></tr>
{foreach $list as $rows}
<tr>
    <td><input type="checkbox" name="art_id" value="{$rows['art_id']}" /></td>
    <td>{$rows['cat_name']}</td>
    <td>{$rows['art_title']}</td>
    <td><img src="/Application/View/Admin/images/{($rows['is_top']==1)?'yes':'no'}.gif"></td>
    <td><img src="/Application/View/Admin/images/{($rows['is_public']==1)?'yes':'no'}.gif"></td>
    <td>{$rows['art_content']}</td>
    <td>{$rows['art_time']|date_format:'%Y-%m-%d %H:%M:%S'}</td>
    <td>
        <a class="button border-blue button-little" href="index.php?p=Admin&c=Article&a=rcRb&art_id={$rows['art_id']}" onclick="return confirm('确认还原?')">还原</a>
        <a class="button border-yellow button-little" href="index.php?p=Admin&c=Article&a=delRb&art_id={$rows['art_id']}" onclick="return confirm('确认删除?')">删除</a>
    </td>
</tr>
{/foreach}
        </table>
</form>
        {$page_str}
    </div>
    <br />
    <p class="text-right text-gray">基于<a class="text-gray" target="_blank" href="#">传智播客</a>构建</p>
</div>
</body>
</html>